enum ACTION{
    //%block="kicking with left foot"
    1,
    //%block="kicking with the right foot"
    2,
    //%block="four legged standing"
    3,
    //%block="sit down"
    4,
    //%block="get down"
    5,
    //%block="stand on both feet"
    6,
    //%block="handshake"
    7,
    //%block="zuoyi"
    8,
    //%block="nodding"
    9,
    //%block="boxing"
    10,
    //%block="stretch oneself"
    11,
    //%block="pee"
    12,
    //%block="push up"
    13,
    //%block="turn PITCH"
    14,
    //%block="turn ROLL"
    15,

}

enum MOTION{
    //%block="stop it"
    0,
    //%block="Minor right front turn"
    1,
    //%block="Significant right front turn"
    2,
    //%block="advance"
    3,
    //%block="Significant left front turn"
    4,
    //%block="Minor left front turn"
    5,
    //%block="Significant left back turn"
    6,
    //%block="backward"
    7,
    //%block="Significant right back turn"
    8,
}
enum BOOLNUMBER{
    //%block="关闭"
    0,
    //%block="开启"
    1,
}
//% color="#33CCFF" iconWidth=50 iconHeight=40
namespace MechDog{

      //% block="initializationMechDog Soft serial portRX[RX]TX[TX]" blockType="command"
      //% RX.shadow="dropdown" TX.shadow="dropdown" TX.options="PIN_DigitalWrite" RX.options="PIN_DigitalRead"
      export function AI_init(parameter: any, block: any) {
        let rx = parameter.RX.code
        let tx = parameter.TX.code
        Generator.addInclude('XYXKC_MechDogInclude', '#include <XYXKC_MechDog.h>');
        Generator.addObject('XYXKC_MechDogObject', 'XYXKC_MechDog',`XYXKC_MechDog(${rx}, ${tx});`);

        Generator.addSetup(`XYXKC_MechDogSetup`,`XYXKC_MechDog.begin();`)


      }
    //% block="MechDog implement[MOTION]" blockType="command"
    //% MOTION.shadow="dropdown"  MOTION.options="MOTION" MOTION.defl="MOTION.0"
    export function MOTION(parameter: any, block: any) {
        let motion = parameter.MOTION.code
        Generator.addCode(`XYXKC_MechDog.motion(${motion});`)
    }

    //% block="MechDog Execute action[ACTION]" blockType="command"
    //% ACTION.shadow="dropdown"  ACTION.options="ACTION" ACTION.defl="ACTION.1"
    export function runningAction(parameter: any, block: any) {
        let action = parameter.ACTION.code
        Generator.addCode(`XYXKC_MechDog.runningAction(${action});`)
    }
    //% block="MechDog [BOOLNUMBER]ultrasonic obstacle avoidance function" blockType="command"
    //% BOOLNUMBER.shadow="dropdown"  BOOLNUMBER.options="BOOLNUMBER" BOOLNUMBER.defl="BOOLNUMBER.0"
    export function ultrasonicObstacleAvoidance(parameter: any, block: any) {
        let boolNumber = parameter.BOOLNUMBER.code
        Generator.addCode(`XYXKC_MechDog.ultrasonicObstacleAvoidance(${boolNumber});`)
    }

    //% block="MechDog Obtain ultrasonic distance mm" blockType="reporter"
    export function getUltrasonic(parameter: any, block: any) {
      Generator.addCode(`XYXKC_MechDog.getUltrasonic()`)
    }
    //% block="MechDog obtain battery level mv" blockType="reporter"
    export function getElectricityLevel(parameter: any, block: any) {
        Generator.addCode(`XYXKC_MechDog.getElectricityLevel()`)
    }





}